package com.wing.bill.controller.admin;

import com.wing.bill.service.TempStorageReportService;
import com.wing.common.utils.JsonResult;
import com.wing.common.utils.PageResult;
import com.wing.web.utils.JwtUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Validated
@Api(value = "Admin-刀具柜暂存报表", tags = "#/bill/tempStorageReport")
@RestController("tempStorageReportController")
@RequestMapping("bill/admin/tempStorageReport")
@RequiredArgsConstructor
public class TempStorageReportController {

    private final TempStorageReportService tempStorageReportService;

    @ApiOperation(value = "顶部折线图", notes = "搜索")
    @GetMapping("/list")
    public JsonResult list(
            @RequestParam("param")String param  //qua 数量 money金额
    ){
        return tempStorageReportService.list(param, JwtUtils.getEnterpriseCode());
    }

    @ApiOperation(value = "顶部格子数据", notes = "搜索")
    @GetMapping("/topCell")
    public JsonResult topCell(
            @RequestParam("type")String type//012 当日当周当月
            , @RequestParam("startTime")String startTime//时间搜索 开始时间
            , @RequestParam("endTime")String endTime//时间搜索 结束时间
            , @RequestParam("mainCabCode") String mainCabCode //主柜选择
            ,@RequestParam("click")String click//顶部数据点击
    ){
        return tempStorageReportService.topCell(type,startTime,endTime,mainCabCode,JwtUtils.getEnterpriseCode(),Integer.valueOf(click));
    }

    @ApiOperation(value = "中部第一个图", notes = "搜索")
    @GetMapping("/midFirstChart")
    public JsonResult midFirstChart(
            @RequestParam("type")String type//012 当日当周当月
            , @RequestParam("startTime")String startTime//时间搜索 开始时间
            , @RequestParam("endTime")String endTime//时间搜索 结束时间
            , @RequestParam("mainCabCode") String mainCabCode //主柜选择
            , @RequestParam("param")String param  //qua 数量 money金额
    ){
        return tempStorageReportService.midFirstChart(type,startTime,endTime,mainCabCode,JwtUtils.getEnterpriseCode(),param);
    }

    @ApiOperation(value = "中部第二个图", notes = "搜索")
    @GetMapping("/midSecondChart")
    public JsonResult midSecondChart(
            @RequestParam("type")String type//012 当日当周当月
            , @RequestParam("startTime")String startTime//时间搜索 开始时间
            , @RequestParam("endTime")String endTime//时间搜索 结束时间
            , @RequestParam("mainCabCode") String mainCabCode //主柜选择
            , @RequestParam("param")String param  //qua 数量 money金额
    ){
        return tempStorageReportService.midSecondChart(type,startTime,endTime,mainCabCode,JwtUtils.getEnterpriseCode(),param);
    }

    @ApiOperation(value = "中部第三个图", notes = "搜索")
    @GetMapping("/midThirdChart")
    public JsonResult midThirdChart(
            @RequestParam("type")String type//012 当日当周当月
            , @RequestParam("startTime")String startTime//时间搜索 开始时间
            , @RequestParam("endTime")String endTime//时间搜索 结束时间
            , @RequestParam("mainCabCode") String mainCabCode //主柜选择
            , @RequestParam("param")String param  //qua 数量 money金额
    ){
        return tempStorageReportService.midThirdChart(type,startTime,endTime,mainCabCode,JwtUtils.getEnterpriseCode(),param);
    }

    @ApiOperation(value = "中部第四个图", notes = "搜索")
    @GetMapping("/midFourthChart")
    public JsonResult midFourthChart(
            @RequestParam("type")String type//012 当日当周当月
            , @RequestParam("startTime")String startTime//时间搜索 开始时间
            , @RequestParam("endTime")String endTime//时间搜索 结束时间
            , @RequestParam("mainCabCode") String mainCabCode //主柜选择
            , @RequestParam("param")String param  //time 时间 num 次数
    ){
        return tempStorageReportService.midFourthChart(type,startTime,endTime,mainCabCode,JwtUtils.getEnterpriseCode(),param);
    }

    @ApiOperation(value = "中部第五个图", notes = "搜索")
    @GetMapping("/midFifthChart")
    public JsonResult midFifthChart(
            @RequestParam("type")String type//012 当日当周当月
            , @RequestParam("startTime")String startTime//时间搜索 开始时间
            , @RequestParam("endTime")String endTime//时间搜索 结束时间
            , @RequestParam("mainCabCode") String mainCabCode //主柜选择
    ){
        return tempStorageReportService.midFifthChart(type,startTime,endTime,mainCabCode,JwtUtils.getEnterpriseCode());
    }

    @ApiOperation(value = "底部列表", notes = "搜索")
    @GetMapping("/data")
    public PageResult data(
            @RequestParam(defaultValue = "1") Integer page
            ,@RequestParam(defaultValue = "10") Integer limit
            ,@RequestParam(defaultValue = "create_time") String sort
            ,@RequestParam(defaultValue = "desc") String order
            ,@RequestParam("startTime")String startTime
            ,@RequestParam("endTime")String endTime
            ,@RequestParam("type")String type
            ,String mainCabCode
    ){
        return tempStorageReportService.data(page,limit,sort,order,startTime,endTime,type,mainCabCode);
    }
}
